<@t.header>
<link rel="stylesheet" href="${request.contextPath}/app/contract/css/contract-create.css">
</@t.header> <@t.body>
<div class="navbar navbar-default navbar-fixed-top padding-0 margin-0">
	<div class="container-fluid">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#suredy-form-navbar">
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			</button>
			<span class="navbar-brand">
				<i class="icon-paste icon-large"></i>
				新的${type.value}
			</span>
		</div>
		<div class="collapse navbar-collapse" id="suredy-form-navbar">
			<ul class="nav navbar-nav suredy-form-bar">
				<li>
					<a href="javascript:void(0);" class="submit-contract-info">
						<i class="icon-ok icon-large"></i>
						提交
					</a>
				</li>
				<li>
					<a href="javascript:void(0);" class="reset-form-info">
						<i class="icon-undo icon-large"></i>
						重置表单
					</a>
				</li>
			</ul>
		</div>
	</div>
</div>

<div class="container" style="padding-top: 60px;">
	<form class="form-create-contract" action="${request.contextPath}/contract/create" method="post" enctype="multipart/form-data">
		<input type="hidden" name="type" value="${type}">
		<input type="hidden" name="status" value="WAIT">

		<div class="panel panel-primary">
			<div class="panel-heading">
				<h3 class="panel-title">
					基本信息 <#if 'B_CONTRACT'==type>
					<div class="btn btn-xs btn-danger bidding-create pull-right" style="margin-top: -2px;">
						<i class="icon-plus"></i>
						新建设单位
					</div>
					</#if>
				</h3>
			</div>
			<div class="panel-body" style="padding-bottom: 0;">
				<div class="row">
					<div class="col-md-12">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										金额类型
									</div>
								</div>
								<select class="form-control not-empty" name="moneyType">
									<#if mtype??> <#list mtype as mt>
									<option value="${mt}">${mt.value}</option>
									</#list> </#if>
								</select>
							</div>
						</div>
					</div>
					<div class="col-md-12">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										合同名称
									</div>
								</div>
								<input type="text" class="form-control not-empty" name="name" value="${name}" placeholder="最多100个汉字">
							</div>
						</div>
					</div>
					<div class="col-md-6">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										建设单位
									</div>
								</div>
								<select class="form-control not-empty" name="companyA">
									<#if 'A_CONTRACT'==type && company??> <#list company as c>
									<option value="${c}">${c}</option>
									</#list> <#else> <#if biddingers??> <#list biddingers as bs>
									<option value="${bs.company}">${bs.company}</option>
									</#list> </#if> </#if>
								</select>
							</div>
						</div>
					</div>
					<div class="col-md-6">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										承建单位
									</div>
								</div>
								<#if 'B_CONTRACT'==type && company??>
								<select class="form-control not-empty" name="companyB">
									<#list company as c>
									<option value="${c}">${c}</option>
									</#list>
								</select>
								<#else>
								<input type="text" class="form-control not-empty" name="companyB" value="${data.companyB}">
								</#if>
							</div>
						</div>
					</div>
					<div class="col-md-6">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										合同编号
									</div>
								</div>
								<input type="text" class="form-control not-empty" name="no" value="${no}" placeholder="最多50个字符">
							</div>
						</div>
					</div>
					<div class="col-md-6">
						<div class="form-group">
							<div class="input-group money-type">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										<span class="money-text"></span>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="col-md-6">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										签订日期
									</div>
								</div>
								<input type="text" class="form-control not-empty datetimepicker" name="signDate" data-foot="false" data-format="yyyy-MM-dd" data-time="${.now}" readonly="readonly">
							</div>
						</div>
					</div>
					<div class="col-md-6">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										办结日期
									</div>
								</div>
								<input type="text" class="form-control not-empty datetimepicker" name="bjTime" data-foot="false" data-format="yyyy-MM-dd" readonly="readonly" placeholder="请选择日期">
							</div>
						</div>
					</div>
					<div class="col-md-12">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										合同工期
										<small class="text-danger contract-days-helper" style="font-weight: bold; cursor: pointer;">？</small>
									</div>
								</div>
								<input type="text" class="form-control datetimepicker" name="contractStart" data-foot="false" data-format="yyyy-MM-dd" readonly="readonly" placeholder="开工日期">
								<div class="input-group-addon" style="border-left: none; border-right: none;">至</div>
								<input type="text" class="form-control datetimepicker" name="contractEnd" data-foot="false" data-format="yyyy-MM-dd" readonly="readonly" placeholder="竣工日期">
								<div class="input-group-addon" style="border-left: none; border-right: none;">工期天数</div>
								<input type="text" class="form-control number" name="contractDays" placeholder="工期天数">
								<div class="input-group-addon" style="border-left: none;">天</div>
							</div>
						</div>
					</div>
					<div class="col-md-12">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										结算方式
									</div>
								</div>
								<textarea rows="3" class="form-control not-empty" name="jiesuanWay" placeholder="最多500个汉字"></textarea>
							</div>
						</div>
					</div>
					<div class="col-md-12">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										付款方式
									</div>
								</div>
								<textarea rows="3" class="form-control not-empty" name="fukuanWay" placeholder="最多500个汉字"></textarea>
							</div>
						</div>
					</div>
					<div class="col-md-12">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										工程内容
									</div>
								</div>
								<textarea rows="3" class="form-control not-empty" name="mainContent" placeholder="最多1000个汉字。"></textarea>
							</div>
						</div>
					</div>
					<div class="col-md-12">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										承包范围
									</div>
								</div>
								<textarea rows="3" class="form-control not-empty" name="chengbaoFanwei" placeholder="最多1000个汉字。"></textarea>
							</div>
						</div>
					</div>
					<div class="col-md-12">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">备注</div>
								</div>
								<textarea rows="3" class="form-control" name="remark" placeholder="最多1000个汉字"></textarea>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="panel panel-success">
			<div class="panel-heading">
				<h3 class="panel-title">相关文件</h3>
			</div>
			<div class="panel-body" style="padding-bottom: 0;">
				<div class="row">
					<div class="col-md-12">
						<div class="form-group">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">
										<span class="not-null-star">*</span>
										合同文件
									</div>
								</div>
								<input type="file" class="hidden" name="contractFile" data-suffix=".pdf, .jpeg, .jpg">
								<input type="text" class="form-control not-empty file-show" placeholder="请选择相关文件。格式只能是[.pdf, .jpeg, .jpg]中的一个！" readonly="readonly">
							</div>
						</div>
					</div>
					<div class="col-md-12 file-items">
						<div class="form-group item">
							<div class="input-group">
								<div class="input-group-addon">
									<div class="form-item-title">附件资料</div>
								</div>
								<input type="file" class="hidden" name="file" data-suffix=".rar, .zip">
								<input type="text" class="form-control file-show" placeholder="请选择附件资料。格式只能是[.rar, .zip]中的一个！" readonly="readonly">
								<div class="btn input-group-addon file-remove">
									<i class="icon-remove text-danger"></i>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<hr style="margin-top: 5px;">
	</form>
</div>
</@t.body> <@t.foot>
<script src="${request.contextPath}/core/js/jquery.form.js"></script>
<script src="${request.contextPath}/js/suredy-modal.js"></script>
<script src="${request.contextPath}/js/suredy-datetimepicker.js"></script>
<script src="${request.contextPath}/app/js/file.js"></script>
<script src="${request.contextPath}/app/flow/js/flow.js"></script>
<script src="${request.contextPath}/app/js/form-checker.js"></script>
<script src="${request.contextPath}/app/contract/js/contract-create.js"></script>

<script type="text/javascript">
	$(function() {
		var html = $('.money-type').html();

		var resetMoneyStyle = function() {
			$('.money-type').parent().removeClass('has-error');
			var mt = $('[name="moneyType"]').val();

			if ('TOTAL' == mt) {
				$('.money-type').html(html);
				$('.money-text').text('合同总价');
				$('.money-type').append('<input type="text" class="form-control not-empty number" name="price" value="${data.price}" placeholder="只能是数字"><div class="input-group-addon">元</div>');
			} else if ('SINGLE' == mt) {
				$('.money-type').html(html);
				$('.money-text').text('合同单价');
				$('.money-type').append('<textarea rows="1" class="form-control not-empty" name="priceDes" style="resize:none;" onfocus="$(this).attr(\'rows\', 5);" onblur="$(this).attr(\'rows\', 1);" placeholder="最多500个汉字">${data.priceDes}</textarea>');
			} else if ('DROP_POINT' == mt) {
				$('.money-type').html(html);
				$('.money-text').text('合同降点');
				$('.money-type').append('<textarea rows="1" class="form-control not-empty" name="priceDes" style="resize:none;" onfocus="$(this).attr(\'rows\', 5);" onblur="$(this).attr(\'rows\', 1);" placeholder="最多500个汉字">${data.priceDes}</textarea>');
			}
		}

		$('[name="moneyType"]').on('change', function() {
			resetMoneyStyle();
		});

		resetMoneyStyle();
	});
</script>
</@t.foot>
